import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s=in.nextLine();
        for (int i=0;i<s.length();i++){
            if (s.charAt(i)==s.charAt(i+1)) {
                System.out.println("2");
            }
        }
        int left=0,right=s.length()-1;
        while (left<=right){
            if(s.charAt(left)==s.charAt(right)){
                left++;
                right++;
                if(left==right||left==right-1){
                    System.out.println("-1");
                }
            }else{

            }
        }

    }
}
